<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%@ include file="../../common/jsp/sheetHeader.jsp" %>
<script>
	$(document).ready(function() {
		//sheet 초기화  
		createIBSheet2(document.getElementById("viewArea"),"mySheet","100%","300px");
		
		var cfg = {FrozenCol:3,SearchMode:smLazyLoad,Page:30,MergeSheet:msPrevColumnMerge};
		var headers = [
			{Text:"NO|상태|삭제|체크박스|더미체크|라디오|텍스트|멀티라인|콤보|Edit콤보|팝업|Edit팝업|정수|실수|계산1\n(실수/3)|계산2\n(계산1*2)|정수(Null)|실수(Null)|년월일|년월|월일|시분초|시분|주민등록번호|사업자번호|카드번호|우편번호|주민번호마스킹|이미지|암호",Align:"Center"}
		];
		var info = {Sort:1,ColMove:1,ColResize:1,HeaderCheck:0};
		var cols = [
			{Type:"Seq",Width:50,SaveName:"sSeq",Align:"Center"},
			{Type:"Status",Width:50,SaveName:"sStatus",Align:"Center"},
			{Type:"DelCheck",Width:50,SaveName:"sDelete",Align:"Center",Hidden:1},
			{Type:"CheckBox",Width:80,SaveName:"sCheck",Align:"Center",Hidden:1},
			{Type:"DummyCheck",Width:70,SaveName:"sDummy",Align:"Center",HeaderCheck:0},
			{Type:"Radio",Width:60,SaveName:"sRadio",Align:"Center"},
			{Type:"Text",Width:70,SaveName:"sText",Align:"Center",KeyField:1,ColMerge:1,Wrap:1, BackColor:'#FF9E9B'},
			{Type:"Text",Width:70,SaveName:"sMultiLine",Align:"Center", MultiLineText:1},
			{Type:"Combo",Width:85,SaveName:"sCombo",Align:"Center",ColMerge:0,ComboText:"전체|평일|주말|여름성수기|겨울성수기",ComboCode:"*|1|2|3|4"},
			{Type:"ComboEdit",Width:80,SaveName:"sComboEdit",Align:"Left",ColMerge:0,ComboText:"전체|한화콘도|한국콘도|글로리콘도|삼립하일라|두산콘도",ComboCode:"100|101|105|110|115|120"},
			{Type:"Popup",Width:130,SaveName:"sPopup",Align:"Left",ColMerge:0},
			{Type:"PopupEdit",Width:65,SaveName:"sPopupEdit",Align:"Right"},
			{Type:"AutoSum",Width:80,SaveName:"sInteger",Align:"Right",ColMerge:0,Format:"Integer"},
			{Type:"AutoSum",Width:80,SaveName:"sFloat",Align:"Right",ColMerge:0,Format:"Float",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sFloatCalc",Align:"Right",ColMerge:0,Format:"Float",CalcLogic:"|13|/3",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sNullFloatCalc",Align:"Right",ColMerge:0,Format:"NullFloat",CalcLogic:"|14|*2",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sNullInteger",Align:"Right",ColMerge:0,Format:"NullInteger"},
			{Type:"AutoSum",Width:80,SaveName:"sNullFloat",Align:"Right",ColMerge:0,Format:"NullFloat",PointCount:2},
			{Type:"Date",Width:90,SaveName:"sDateYmd",Align:"Center",ColMerge:0,Format:"Ymd"},
			{Type:"Date",Width:80,SaveName:"sDateYm",Align:"Center",ColMerge:0,Format:"Ym"},
			{Type:"Date",Width:70,SaveName:"sDateMd",Align:"Center",ColMerge:0,Format:"Md"},
			{Type:"Date",Width:60,SaveName:"sDateHms",Align:"Center",ColMerge:0,Format:"Hms"},
			{Type:"Date",Width:60,SaveName:"sDateHm",Align:"Center",ColMerge:0,Format:"Hm"},
			{Type:"Text",Width:120,SaveName:"sTextId",Align:"Center",ColMerge:0,Format:"IdNo"},
			{Type:"Text",Width:110,SaveName:"sTextSaup",Align:"Center",ColMerge:0,Format:"SaupNo"},
			{Type:"Text",Width:140,SaveName:"sTextCard",Align:"Center",ColMerge:0,Format:"CardNo"},
			{Type:"Text",Width:90,SaveName:"sTextPost",Align:"Center",ColMerge:0,Format:"PostNo"},
			{Type:"Text",Width:120,SaveName:"sUserFormat",Align:"Center",ColMerge:0,Format: "######-*******"},
			{Type:"Image",Width:70,SaveName:"sImage",Align:"Center",ColMerge:0},
			{Type:"Pass",Width:70,SaveName:"sPass",Align:"Center",ColMerge:0}
		];
	
		mySheet.SetConfig(cfg);
		mySheet.InitHeaders(headers,info);
		mySheet.InitColumns(cols);
		
		createIBSheet2(document.getElementById("viewArea2"),"mySheet2","100%","300px");
		
		var headers2	= [
				{Text:"NO|상태|삭제|문자열|콤보|콤보에디트|팝업|팝업에디트|자동합계|자동평균|정수|실수|날짜|패스워드|체크박스|라디오", Align:"Center"}
		];
		
		var cols2 = [
					{Type:"Seq", Align:"Right", VAlign:"Middle"},
					{Type:"Status", Align:"Center"},
					{Type:"DelCheck"},
					{Type:"Text", KeyField:1, Align:"Center"},
					{Type:"Combo", Width:80, ComboText:"대기|진행중|완료", ComboCode:"01|02|03",PopupText:"대기|진행중|완료"},
					{Type:"ComboEdit", Width:80, ComboText:"고려대학교|고려대학교2|국민대학교|서울대학교|숙명여자대학교|연세대학교|울산대학교|울산과학기술대학교|이화여자대학교|인천대학교|인천가톨릭대학교"},
					{Type:"Popup", Width:100},
					{Type:"PopupEdit", Width:100},
					{Type:"AutoSum", Align:"Right",Width:70,Format:"NullInteger"},
					{Type:"AutoAvg", Align:"Right",Width:70, Format:"NullFloat"},
					{Type:"Int", Align:"Right", Format:"Integer",Width:70, Hidden:1},
					{Type:"Float", Align:"Right", Format:"Float",Width:70, Hidden:1},
					{Type:"Date", Align:"Center", Format:"Ymd", Width:100},
					{Type:"Pass", Hidden:1},
					{Type:"CheckBox"},
					{Type:"Radio"}
		          ];
		
		
		mySheet2.SetConfig(cfg);
		mySheet2.InitHeaders(headers2,info);
		mySheet2.InitColumns(cols2);
	
		doAction("search");
	});
	
	function down2excel() {
		var cmd = $('#cmdDown').val();
		eval(cmd);
	}
	
	/*Sheet 각종 처리*/
	function doAction(sAction) {
		switch(sAction) {
			case "search":		//조회
				mySheet.DoSearch("../data/Down2Excel_data.xml");
				mySheet2.DoSearch("../data/sheet_data.xml");
				break;
		}
	}
	
</script>
<title>여러개 시트 동시 다운로드 예제</title>
</head>
<body>
<div id="main">
	<%@ include file="../../common/jsp/sheetNavi.jsp" %>	
	<div id="title">여러개 시트 동시 다운로드 예제</div>
	<div id="desc">
		여러 개의 시트로부터 1개의 엑셀 문서로 다운로드 받는다.<br>
		Down2ExcelBuffer 의 buffer 인자를 true 로 설정하면 이후로 실행되는Down2Excel은 실제로 동작하지 않으며 모두 내부 메모리에 버퍼링된다.<br> 
		이후에 Down2ExcelBuffer 의 buffer 인자를 false 로 설정하는 순간 버퍼링된 모든 시트들을 하나의 엑셀 파일안에 시트별로 각각의 워크시트에 저장되어 다운로드 된다. 
		<br>
		<br>
		<table width="500" border="1" cellspacing="0" cellpadding="2" bordercolor="#AAAAAA" style="border-collapse:collapse;text-align:center" rules="rows" frame="hsides">
			<tr>
				<td>파라미터</td>
				<td>타입	</td>
				<td>필수여부</td>
				<td>설명</td>
			</tr>
			<tr>
				<td>IsBuffer</td>
				<td>bool</td>
				<td>필수</td>
				<td align="left" style="padding-left:10px">
					버퍼링 여부
				</td>
			</tr>
		</table>
		<br>
		//이후로는 버퍼링한다. 아무 동작 안함.<br>
		firstSheet.Down2ExcelBuffer(true);<br>
		<br>
		// 첫번째 워크시트에 담아두기를 예약함.<br>
		firstSheet.Down2Excel({FileName:'excel2',SheetName:'sheet1'});<br> 
		<br>
		// 두번째 워크시트에 담아두기를 예약함.<br>
		secondSheet.Down2Excel({FileName:'excel2',SheetName:' sheet2'});<br> 
		<br>
		// 버퍼링된 모든 엑셀 자료를 1개의 엑셀문서에 모두 모아서 즉시 다운로드 한다.<br>
		firstSheet.Down2ExcelBuffer(false);
	</div>

	<div id="functionArea">
		<textarea id="cmdDown" rows="4" cols="90">mySheet.Down2ExcelBuffer(true);
mySheet.Down2Excel({FileName:'excel2',SheetName:'sheet1'});
mySheet2.Down2Excel({FileName:'excel2',SheetName:' sheet2'});
mySheet.Down2ExcelBuffer(false);</textarea>
		<br>
		<input type="button" id="btnExe" value="엑셀 파일 다운로드" onclick="down2excel()">
	</div>
	
	<div id="viewArea">
	</div>
	<div id="viewArea2">
	</div>
</div>
</body>
</html>